<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>yukari world</title>
<#include "/lib/base_source.ftl">
<style type="text/css">
</style>
</head>
<body>
<div class='whole-container'>
<#include "/lib/header.ftl">
    <div>
        <ul class="breadcrumb">
        	<li>夏季巡演</li><span class="divider">/</span>
            <li>报名人员列表</li>
        </ul>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="container span12">
            <#include "/lib/alert.ftl">

                <div class='main-content'>
                    <div class="well form-inline">
                        <div class='main-action'>
                            <select name="city" id="city" onchange="reloadUrl()">
                                <option value="chengdu" <#if city == "chengdu">selected="selected"</#if>>成都</option>
                                <option value="beijing" <#if city == "beijing">selected="selected"</#if>>北京</option>
                                <option value="guangzhou" <#if city == "guangzhou">selected="selected"</#if>>广州</option>
                                <option value="shanghai" <#if city == "shanghai">selected="selected"</#if>>上海</option>
                            </select>
                            <select name="status" id="status" onchange="showList()">
                                <option value="">全部</option>
                                <option value="-1" <#if status == -1>selected="selected"</#if>>未报名</option>
                                <option value="0" <#if status == 0>selected="selected"</#if>>已报名</option>
                                <option value="1" <#if status == 1>selected="selected"</#if>>有门票</option>
                                <option value="2" <#if status == 2>selected="selected"</#if>>已入场</option>
                                <option value="-2" <#if status == -2>selected="selected"</#if>>废票</option>
                            </select>
                            <input type="text" name="name" id="name" value="${name!}" oninput="showList()">
                        </div>
                    </div>
                    <div>
                        人数: <span id="countP">${size}</span>
                    </div>
                    <div class="table-content">
                    <#-- table -->
                        <table class="table table-striped table-bordered table-condensed" id="itemTable" style="font-size:12px;word-break:break-all;word-wrap:break-word;">
                            <thead>
                            <tr>
                                <th>报名人</th>
                                <th>手机</th>
                                <th>QQ</th>
                                <th>状态</th>
                                <th>屏蔽</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <#if list??>
                            <#list list as item>
                            	<tr data-status="${item.status}" data-name="${item.douyuName}" class="item">
                                	<td>${item.douyuName}</td>
                                	<td>${item.phone!}</td>
                                	<td>${item.qq!}</td>
                                	<td>
                                        <#if item.status == 0>
                                            已报名
                                        <#elseif item.status == 1>
                                            有门票
                                        <#elseif item.status == -1>
                                            未报名
                                        <#elseif item.status == -2>
                                            废票
                                        <#elseif item.status == 2>
                                            已入场
                                        </#if>
                                    </td>
                                    <td>
                                        <#if item.exclude == 0>
                                            正常
                                        <#else>
                                            已屏蔽
                                        </#if>
                                    </td>
									<td>
                                        <#if item.exclude == 0>
                                            <a href="javascript:" onclick="updateExclude(${item.id},1)" class="btn btn-sm btn-danger">屏蔽抽奖</a>
                                        <#else>
                                            <a href="javascript:" onclick="updateExclude(${item.id},0)" class="btn btn-sm btn-success">取消屏蔽</a>
                                        </#if>
                                        <#if item.status == -1>
                                        <a href="javascript:" onclick="ticketUpdateStatus(${item.id},'${item.city}',1)" class="btn btn-sm btn-success">给予门票</a>
                                        <#elseif item.status == 0>
                                        <a href="javascript:" onclick="ticketUpdateStatus(${item.id},'${item.city}',-1)" class="btn btn-sm btn-info">取消报名</a>
                                        <a href="javascript:" onclick="ticketUpdateStatus(${item.id},'${item.city}',1)" class="btn btn-sm btn-success">给予门票</a>
                                        <#elseif item.status == 1>
                                        <a href="javascript:" onclick="ticketUpdateStatus(${item.id},'${item.city}',0)" class="btn btn-sm btn-warning">收回门票</a>
                                        <a href="javascript:" onclick="ticketUpdateStatus(${item.id},'${item.city}',-2)" class="btn btn-sm btn-danger">废票</a>
                                        </#if>

									</td>
                                </tr>
                            </#list>
                            </#if>
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    $(document).ready(function(){
        showList();
    });
    function showList(){
        var status = $("#status").val();
        var name = $("#name").val();
        var trs = $(".item");
        var size = 0;
        trs.each(function(i,o){
            var t = $(o);
            var ds = t.attr("data-status");
            var dn = t.attr("data-name");
            if ((status == "" ||  ds == status) && (name == "" || dn.indexOf(name) != -1)){
                t.show();
                size++;
            } else {
                t.hide();
            }
        })
        $("#countP").html(size);
    }

    function ticketUpdateStatus(id,city,status){
        $.ajax({
            url : "${rc.contextPath}/admin/tour/ticket/update",
            dataType : "json",
            data : {"tourId":id,"city":city,"status":status},
            type:'post',
            success:function(json){
                if (json.code == 0){
                    reloadUrl();
                } else {
                    alert(json.message);
                }
            }
        });
    }

    function updateExclude(id,exclude){
        $.ajax({
            url : "${rc.contextPath}/admin/tour/exclude/update",
            dataType : "json",
            data : {"id":id,"exclude":exclude},
            type:'post',
            success:function(json){
                if (json.code == 0){
                    reloadUrl();
                } else {
                    alert(json.message);
                }
            }
        });
    }

    function reloadUrl(){
        location.href = "${rc.contextPath}/admin/tour/list?city="+$("#city").val()+"&name="+$("#name").val()+"&status="+$("#status").val()
    }



</script>
</body>
</html>